{include file="../application/admin/view/header.html" /}
<link href="/static/css/summernote.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/static/css/summernote-bs4.css">
<link rel="stylesheet" type="text/css" href="/static/css/summernote-lite.css">
</head>
<body>
<div class="container">
  <div class="col-md-12">
    <div class="alert kesn_prompt"></div>
  </div>
  <div class="row input-group col-md-4" style="display: none">
    <span class="input-group-addon">ID</span>
    <input type="text" class="form-control" placeholder="" value="{$announcement.id}" name="announcement_id"/>
  </div>
  
	<div class="row input-group col-md-4">
	  <span class="input-group-addon">公告名</span>
	  <input type="text" class="form-control" placeholder="" value="{$announcement.announcement}" name="announcement_name"/>
	</div>
	<br />
  <div class="row input-group col-md-4">
    <span class="input-group-addon">描述</span>
    <input type="text" class="form-control" placeholder="" value="{$announcement.descr}" name="announcement_descr"/>
  </div>
  <br/>
	<div class="row">
		<form method="post">
		  <textarea id="summernote" name="editordata">{$announcement.content}</textarea>
		</form>
     <br/>
  <button class="btn btn-info col-md-offset-9 save_announcement">保存</button>
	</div>
 
</div>



{include file="../application/admin/view/footer.html" /}
<script src="/static/js/summernote.js"></script>
<script type="text/javascript" src="/static/js/summernote-bs4.js"></script>
<script type="text/javascript" src="/static/js/summernote-lite.js"></script>
<script type="text/javascript" src="/static/lang/summernote-zh-CN.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  $('#summernote').summernote({
  	minHeight: 400,
  	lang: 'zh-CN',
  	});
});
//保存教程
$('.save_announcement').click(function(){
  var announcement_info = {};
  announcement_info['id'] = $('input[name=announcement_id]').val();
  announcement_info['descr'] = $.trim($('input[name=announcement_descr]').val());
  announcement_info['announcement'] = $.trim($('input[name=announcement_name]').val());
  announcement_info['content'] = $('textarea[name=editordata]').val();
  for(var key in announcement_info){
    announcement_info[key] = $.trim(announcement_info[key]);
    if (announcement_info[key] == '') {
      kesn_prompt('fail','请完整填充公告内容！');
      return;
    }
  }
  $.ajax({
      url : 'save_content',
      async:true,
      type:'POST',
      data:announcement_info,
      dataType:'JSON',
      success:function(data,textStatus,jqXHR){
            if (data.err != 0) {
              kesn_prompt('fail',data.content);
            }else if (data.err == 0) {
                      kesn_prompt('success','保存成功！');
                    }

          },
          error:function(){
            kesn_prompt('fail','网络出错');
          }
    });

});
</script>
</footer>
</body>
</html>

